package com.mtung.concurrent.controller;

import com.mtung.concurrent.AsyncService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

/**
 * @author zhenguo.yao
 * @date 2020/12/20
 */
@RestController
@RequestMapping("/thread")
public class ThreadController {

    @Autowired
    private AsyncService asyncService;

    @GetMapping
    public String sendSms() throws InterruptedException, ExecutionException {
        Future<String> stringFuture = asyncService.sendFutureSms();
        stringFuture.get();
        return Thread.currentThread().getName() + "结束";
    }

}
